package com.yunhe.rentcars.pro.service.system.impl;

import com.yunhe.rentcars.commons.annoaction.Log;
import com.yunhe.rentcars.commons.dto.Pageable;
import com.yunhe.rentcars.pro.dao.system.ClientLevelDao;
import com.yunhe.rentcars.pro.entity.system.ClientLevel;
import com.yunhe.rentcars.pro.service.system.ClientLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ClientLevelServiceImpl implements ClientLevelService {
    @Autowired
    private ClientLevelDao clientLevelDao;

    @Override
    @Log(value = "添加会员等级")
    public void save(ClientLevel clientLevel) {
        clientLevelDao.save(clientLevel);
    }
    @Override
    @Log(value = "删除会员等级",type = 2)
    public void delete(Long id) {
        clientLevelDao.delete(id);

    }

    @Override
    @Log(value = "修改会员等级",type = 3)
    public void update(ClientLevel clientLevel) {
        clientLevelDao.update(clientLevel);

    }

    @Override
    public Pageable<ClientLevel> findPage(Integer offset, Integer limit) {
        Pageable<ClientLevel> pageable = new Pageable<>();
        List<ClientLevel> rows = new ArrayList<>();
        int count = clientLevelDao.findCount();
        if(count > 0){
            rows = clientLevelDao.findList(offset, limit);
        }
        pageable.setTotal(count);
        pageable.setRows(rows);
        return pageable;
    }

    @Override
    public ClientLevel findOne(Long id) {
        return clientLevelDao.findOne(id);
    }

}
